<script setup>
import { RouterView, RouterLink } from 'vue-router'
</script>

<template>
  <div class="app-container">
    <aside class="sidebar">
      <h2 class="sidebar-title">Pinia 教程</h2>
      <nav class="sidebar-nav">
        <div class="nav-group">
          <h3 class="nav-group-title">基础</h3>
          <RouterLink to="/01" class="nav-link">01.认识pinia</RouterLink>
        </div>
        
        <div class="nav-group">
          <h3 class="nav-group-title">选项式API</h3>
          <RouterLink to="/02" class="nav-link">02.定义store(选项式)</RouterLink>
          <RouterLink to="/03" class="nav-link">03.state(选项式)</RouterLink>
          <RouterLink to="/04" class="nav-link">04.getters(选项式)</RouterLink>
          <RouterLink to="/05" class="nav-link">05.actions(选项式)</RouterLink>
          <RouterLink to="/06" class="nav-link">06.axios(选项式)</RouterLink>
          <RouterLink to="/07" class="nav-link">07.综合案例</RouterLink>
        </div>
        
        <div class="nav-group">
          <h3 class="nav-group-title">组合式API</h3>
          <RouterLink to="/02c" class="nav-link">02.定义store(组合式)</RouterLink>
          <RouterLink to="/03c" class="nav-link">03.state(组合式)</RouterLink>
          <RouterLink to="/04c" class="nav-link">04.getters(组合式)</RouterLink>
          <RouterLink to="/05c" class="nav-link">05.actions(组合式)</RouterLink>
        </div>
        
        <div class="nav-group">
          <h3 class="nav-group-title">Axios教程</h3>
          <RouterLink to="/axios-tutorial" class="nav-link">Axios详细教程</RouterLink>
          <RouterLink to="/axios-guide" class="nav-link">Axios完整指南</RouterLink>
        </div>
      </nav>
    </aside>
    
    <main class="main-content">
      <RouterView />
    </main>
  </div>
</template>

<style>
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f9f9f9;
}

.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 280px;
  background-color: #2c3e50;
  color: white;
  padding: 20px;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-title {
  font-size: 1.5rem;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-group-title {
  font-size: 1rem;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: #4CAF50;
}

.nav-link {
  display: block;
  padding: 8px 10px;
  color: #ddd;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.3s ease;
  margin-bottom: 5px;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-link.router-link-active {
  background-color: #4CAF50;
  color: white;
}

.main-content {
  flex: 1;
  padding: 20px;
  margin-left: 280px;
  width: calc(100% - 280px);
}

/* 移除教程页面中的导航栏，因为我们已经在侧边栏添加了导航 */
.tutorial-nav {
  display: none !important;
}

/* 调整教程页面的标题样式 */
.tutorial-container header {
  margin-bottom: 30px;
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
}

.tutorial-container h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: #2c3e50;
}

.tutorial-container .subtitle {
  font-size: 1.2rem;
  color: #666;
}
</style>
